Put an array of Objects in nodes of another array of Objects [JAVA]
Posted
by zengr
on Stack Overflow
See other posts from Stack Overflow
or by zengr
Published on 2010-05-10T22:48:28Z
Indexed on
2010/05/10
22:54 UTC
Read the original article
Hit count: 168
public class hello
{
public static void main(String[] args)
{
Object[] newarray = new Object[1];
Object[] obj = new Object[2];
obj[0] = "Number1"; //string value
obj[1] = "Number2"; //string value
newarray[0] = obj; //this works
Object[] tmp_obj = new Object[2];
tmp_obj = newarray[0]; //obviously does not work
System.out.println(tmp_obj[0]); //nope
System.out.println(tmp_obj[1]); //nope
}
}
So, now if I want to access the values "Number1" and "Number2" which are stored in obj[0] and obj[1]; obj is in newarray[0]. what should I do?
Is this a possible?
Thanks
© Stack Overflow or respective owner